package responses

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

/**
响应构建器
一般在控制器,路由,中间件用
**/

func Ok(msg string, data interface{}) gin.H {
	return gin.H{
		"code": http.StatusOK,
		"msg":  msg,
		"data": data,
	}
}

func ServerError(msg string, data interface{}) gin.H {
	return gin.H{
		"code": http.StatusInternalServerError,
		"msg":  msg,
		"data": data,
	}
}

func BadRequest(msg string, data interface{}) gin.H {
	return gin.H{
		"code": http.StatusBadRequest,
		"msg":  msg,
		"data": data,
	}
}

func NotFind(msg string, data interface{}) gin.H {
	return gin.H{
		"code": http.StatusNotFound,
		"msg":  msg,
		"data": data,
	}
}

func Unauthorized(msg string, data interface{}) gin.H {
	return gin.H{
		"code": http.StatusUnauthorized,
		"msg":  msg,
		"data": data,
	}
}

func Forbidden(msg string, data interface{}) gin.H {
	return gin.H{
		"code": http.StatusUnauthorized,
		"msg":  msg,
		"data": data,
	}
}

func MethodNotAllowed(msg string, data interface{}) gin.H {
	return gin.H{
		"code": http.StatusMethodNotAllowed,
		"msg":  msg,
		"data": data,
	}
}
